package cn.tedu.imop.content.controller;

import cn.tedu.imop.api.model.RestResult;
import cn.tedu.imop.api.model.RestResultUtils;
import cn.tedu.imop.common.constants.Constants;
import cn.tedu.imop.common.pojo.PageData;
import cn.tedu.imop.content.entity.Article;
import cn.tedu.imop.content.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@Api(tags = "文章管理")
@RestController
@RequestMapping(Constants.CONTROLLER_API_VERSION+"/article")
public class ArticleController {
    private final ArticleService articleService;
    public ArticleController(ArticleService articleService) {
        this.articleService = articleService;
    }
    @ApiOperation("创建文章")
    @PostMapping
    public RestResult<Boolean> createArticle(Article article) {
        articleService.createArticle(article);
        return RestResultUtils.success();
    }
    @ApiOperation("文章列表")
    @GetMapping
    public RestResult<PageData<Article>> getArticleList(Article article) {
        return RestResultUtils.success(articleService.getArticleList(article));
    }

}
